package com.ice.body.hardware.service.impl;

import com.ice.base.util.HexUtil;
import com.ice.base.util.ThreadPoolUtil;
import com.ice.body.hardware.service.HardWareService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;


@Slf4j
@Service
public class HardWareServiceImpl implements HardWareService {

    /**
     * 控制工作台
     * @param cmd
     */
    @Override
    public void handComputer(String cmd){
        ThreadPoolExecutor threadPool = ThreadPoolUtil.getThreadPool();
        threadPool.execute(() -> {
            try {
                System.out.println("多线程开启工作台："+Thread.currentThread().getName());
             /*   // 连接指示灯设备海尔35
                Socket socket = new Socket(InetAddress.getByName("192.168.100.140"), Integer.parseInt("7113"));
                // 得到Socket连接的输出流
                DataOutputStream out = new DataOutputStream(socket.getOutputStream());
                // 向服务器发送数据
                out.write(HexUtil.hex2Bytes(cmd));
                // 立刻发送数据
                out.flush();
                out.close();
                socket.close();*/
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    }
}
